package com.ysd.lis.controller.lab;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.entity.PubReportRules;
import com.ysd.lis.entity.lab.LabRulesVsItemdict;
import com.ysd.lis.mapper.lab.LabRulesVsItemdictMapper;
import com.ysd.lis.request.DeleteParam;
import com.ysd.lis.request.LabRulesVsItemdictDto;
import com.ysd.lis.request.ReportRulesPageParam;
import com.ysd.lis.request.lab.ReportRuleDto;
import com.ysd.lis.service.lab.ReportRulesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * PUB_REPORT_RULES前端控制器
 * </p>
 *
 * @author Bai
 * @since 2023-11-24
 */
@Api(tags = "报告规则管理")
@RestController
@RequestMapping("/api/pub")
public class LabReportRulesController extends BaseController {

    @Autowired
    ReportRulesService pubReportRulesService;
    @Autowired
    LabRulesVsItemdictMapper labRulesVsItemdictMapper;

    @ApiOperation("分页获取报告规则信息")
    @GetMapping("/getReportRulesList")
    public Result getReportRulesList(ReportRulesPageParam reportRulesPageParam) {
        return pubReportRulesService.getPageList(reportRulesPageParam);
    }

    @ApiOperation("获取redis生成的报表另存为名称yyyymmdd001格式")
    @PostMapping("/getReportAsName")
    public Result getReportAsName() {
        return pubReportRulesService.getReportAsName();
    }

    //获取报告单元与工作组的树状结构数据
    @ApiOperation("获取报告单元启用状态的数据")
    @GetMapping("/reportRules/getReportGroup")
    public Result getReportGroupTree(ReportRulesPageParam reportRulesPageParam) {
        return pubReportRulesService.getReportGroupTree(reportRulesPageParam);
    }

    //获取报告单元与工作组的树状结构数据
    @ApiOperation("获取poct报告单元启用状态的数据")
    @GetMapping("/reportRules/getReportGroupPoct")
    public Result getReportGroupPoct(ReportRulesPageParam reportRulesPageParam) {
        return pubReportRulesService.getReportGroupPoct(reportRulesPageParam);
    }

    //根据报告单元id获取规则信息

    @ApiOperation("获取报告单元的规则信息")
    @GetMapping("/reportRules/getReportRulesByGroupId/{rptGroup}")
    public Result getReportRulesByGroupId(@PathVariable("rptGroup") String rptGroup) {
        return pubReportRulesService.getReportRulesByGroupId(rptGroup);
    }

    @ApiOperation("根据规则Id获取报告项目信息")
    @GetMapping("/findDictItemByRules")
    public Result findDictItemByFeeItemId(String rulesId, String type) {
        return pubReportRulesService.findDictItemByRules(rulesId, type);
    }

    @ApiOperation("根据规则Id获取未选中的报告项目信息")
    @GetMapping("/findNotSelectDictItemByRules")
    public Result findNotSelectDictItemByRules(String rulesId) {
        return pubReportRulesService.findNotSelectDictItemByRules(rulesId);
    }

    @ApiOperation("弹框保存规则2与4，规则与报告项目对照")
    @PostMapping("/saveRuleVsItemDict")
    public Result saveRuleVsItemDict(@RequestBody LabRulesVsItemdictDto dto) {
        return pubReportRulesService.saveRuleVsItemDict(dto);
    }

    @ApiOperation("规则四双击存储规则与报告项目对照")
    @PostMapping("/saveRuleVsItemDictRuleFore")
    @Deprecated
    public Result saveRuleVsItemDictRuleFore(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.saveRuleVsItemDictRuleFore(labRulesVsItemdict);
    }


    @ApiOperation("双击被选中的报告项目删除对应关系")
    @PostMapping("/deleleRuleVsItemDict")
    public Result deleleRuleVsItemDict(@RequestBody DeleteParam param) {
        return pubReportRulesService.deleleRuleVsItemDict(param);
    }

    // 规则一中下拉选择报告模版根据规则ID修改或者新增规则
    @ApiOperation("规则一中下拉选择报告模版根据规则ID修改或者新增规则")
    @PostMapping("/updateReportRuleByRuleId1")
    public Result updateReportRuleByRuleId1(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.updateReportRuleByRuleId1(labRulesVsItemdict);
    }

    // 规则二中下拉选择报告模版根据规则ID修改报告模版
    @ApiOperation("规则二中下拉选择报告模版根据规则ID修改报告模版")
    @PostMapping("/updateReportRuleByRuleId2")
    public Result updateReportRuleByRuleId2(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.updateReportRuleByRuleId2(labRulesVsItemdict);
    }

    // 点击保存按钮保存规则三
    @ApiOperation("保存/修改规则二规则三项目超过多少信息")
    @PostMapping("/rulesSave")
    public Result rulesSave(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.rulesSave(labRulesVsItemdict);
    }

    //规则三中下拉选择报告模版根据规则ID修改或者新增规则
    @ApiOperation("保存/修改规则三信息")
    @PostMapping("/updateReportRuleByRuleId3")
    public Result updateReportRuleByRuleId3(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.updateReportRuleByRuleId3(labRulesVsItemdict);
    }

    //规则四中下拉选择报告模版根据规则ID修改或者新增规则
    @ApiOperation("保存/修改规则四信息")
    @PostMapping("/updateReportRuleByRuleId4")
    public Result updateReportRuleByRuleId4(@RequestBody LabRulesVsItemdict labRulesVsItemdict) {
        return pubReportRulesService.updateReportRuleByRuleId4(labRulesVsItemdict);
    }


    @ApiOperation("获取报告单元的特殊规则信息")
    @GetMapping("/getReportRuleListByGroupId")
    public Result getReportRuleListByGroupId(ReportRulesPageParam reportRulesPageParam) {
        return pubReportRulesService.getReportRuleListByGroupId(reportRulesPageParam);
    }

    @ApiOperation("添加报告单元的特殊规则")
    @PostMapping("/addReportRuleList")
    public Result addReportRuleList(@RequestBody PubReportRules reportRules) {
        return pubReportRulesService.addReportRuleList(reportRules);
    }

    @ApiOperation("修改报告单元的特殊规则")
    @PostMapping("/editReportRuleList")
    public Result editReportRuleList(@RequestBody PubReportRules reportRules) {
        return pubReportRulesService.editReportRuleList(reportRules);
    }

    @ApiOperation("删除报告单元的特殊规则")
    @PostMapping("/deleteReportRuleList")
    public Result deleteReportRuleList(@RequestBody ReportRuleDto reportRules) {
        return pubReportRulesService.deleteReportRuleList(reportRules);
    }

    @ApiOperation("删除规则")
    @GetMapping("/deleteReportRule")
    public Result deleteReportRule(String Id) {
        return pubReportRulesService.deleteReportRule(Id);
    }


}
